home *** CD-ROM | disk | FTP | other *** search
- /*[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]*/
- /* UBusyCursor.p */
- /* Copyright © 1985-1990 Apple Computer, Inc. All rights reserved. */
- /*[f-]*/
- /*
- T H E O R Y O F O P E R A T I O N
- The UBusyCursor unit implements a mechanism for automatically setting
- the cursor to the watch when the application is "busy."
- An application is considered "busy" if it hasn't called GetNextEvent
- or EventAvail for a given number of ticks, where 60 ticks equals one
- second. The default time is defined by kWatchDelay, which is 120 ticks
- or 2 seconds--it can be changed by calling BusyDelay. After this period
- of time has elapsed with no call to GetNextEvent or EventAvail, the
- cursor is changed to the watch. On the next call to GetNextEvent or
- EventAvail, the cursor is restored to its state before it was changed to
- the watch.
- Changing the cursor to the watch is done by the VBL task AWatchTask.
- AWatchTask's execution frequency is set to kWatchDelay, or by calling
- BusyDelay. When AWatchTask is executed it sets the cursor to the
- watch and resets AWatchTask's vblCount.
- The traps InitCursor, SetCursor and SetCCursor are patched so that
- they "remember" the cursor being set before executing the trap. This
- will allow us to restore the cursor after it has been changed to the
- busy watch.
- The EventAvail and GetNextEvent traps are patched such that, before
- executing the trap, AWatchTask's vblCount is reset, and if the busy
- cursor is displayed, then the cursor is restored to the last cursor
- set by SetCursor or SetCCursor.
- */
- /*[f+]*/
- #ifndef __UBusyCursor__
- #define __UBusyCursor__ 0
- #endif
- #if ! __UBusyCursor__
- #define __UBusyCursor__ 1
-
- /* • Auto-Include the requirements for this unit's interface. */
- #ifndef __TYPES__
- #include "Types.h"
- #endif
-
- const short kWatchDelay = 2 * 60; /*default # of 1/60 sec. ticks before cursor
- changes to a watch*/
-
- extern pascal void InitUBusyCursor(void);
- /* Initialize the unit. */
-
- extern pascal void BusyActivate(Boolean entering);
- /* Call BusyActivate if you want to activate or deactivate the busy cursor mechanism. Th
- is is
- call by MacApp when losing/gaining control to a desk accessory or switcher partition. */
-
- extern pascal void BusyDelay(short newDelay);
- /* Call BusyDelay if you want to change the busy cursor delay. newDelay should be in 1/60
- seconds; a value <= 0 means don't change the cursor. (BusyDelay respects the state flags
- in the cursor info record (ie., changeToWatch and inControl.) */
-
- extern pascal void ForceBusy(void);
- /* Puts up the watch immediately */
-
- extern pascal void ResetBusyCursor(void);
- /* Call ResetBusyCursor if you want to change the cursor back to an arrow and reset the time
- before changing back to a watch. This is not usually called directly by the application.
- Instead, it is called each time GetNextEvent and EventAvail is called, by patches installed
- by BusyInstall. */
-
- extern pascal void BusyInstall(void);
- /* BusyInstall installs the busy cursor mechanism. Typically this is called once during
- program initialization. It installs the VBL task and patches the traps GetNextEvent,
-
- EventAvail, InitCursor, SetCursor and SetCCursor. */
-
- extern pascal void BusyRemove(void);
- /* BusyRemove uninstalls the busy cursor mechanism. Typically this is called once during
- program termination. It removes the VBL task and unpatches the patched traps. */
- #endif
-
-